package server

import (
	"fmt"
	"gitee.com/ichub/gofactroy/common/ichubbase"
	msg2nats "gitee.com/ichub/gofactroy/nats/msg2nets"
	"github.com/nats-io/nats.go"
	"time"
)

// 邀请码注册消息主题
func regReplyHandler(m *nats.Msg) {
	fmt.Printf("Received a message: %s\n", string(m.Data))
	natsMessage := msg2nats.NatsMessage{}
	err := natsMessage.Unmarshal(string(m.Data))
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(time.Now().Format(ichubbase.FormatDateTime))
	fmt.Println("接收了邀请码注册消息：" + natsMessage.ToString())
	if natsMessage.Body != nil {
		fmt.Println(string(*natsMessage.Body))
	}
}
